package json;

import java.text.SimpleDateFormat;
import java.util.Date;

import net.sf.json.JsonConfig;
import net.sf.json.processors.JsonValueProcessor;

public class DateValuePocesser implements JsonValueProcessor {
	private String format=new String("yyyy-MM-dd");
	private SimpleDateFormat sdf=new SimpleDateFormat(format);

	public Object processArrayValue(Object obj, JsonConfig cfg) {
		return process(obj);
	}

	public Object processObjectValue(String str, Object obj, JsonConfig cfg) {
		return process(obj);
	}
 
	 public Object process(Object obj){
		 if(obj ==null){
			 return ""	;
		 }else if(obj instanceof Date){
			 return sdf.format(obj);
		 }else{			 
			 return obj.toString();
		 }
	 }
}
